FILE_LOCATION   =	"C:\\Users\\Student\\Desktop\\SoapFiles"


setwd(FILE_LOCATION)


PC_FILE<-read.table("parchild.lst",header=F,stringsAsFactors=F)
GC_FILE<-read.table("gparchild.lst",header=F,stringsAsFactors=F)
SIB_FILE<-read.table("siblings.lst",header=F,stringsAsFactors=F)
HSIB_FILE<-read.table("halfsiblings.lst",header=F,stringsAsFactors=F)


poplist<-read.table("PopIndex.txt",header=F)

Lengths1<-read.table("Lengths.txt",header=F)
Numbers2<-read.table("Numbers.txt",header=F)


lengths<-integer(0)
numbers<-integer(0)

for (i in seq(length(PC_FILE[,1])))
{
	if ((A<-which(poplist==PC_FILE[i,1]))<(B<-which(poplist==PC_FILE[i,2])))
	{lengths<-c(lengths,Lengths[A,B])
	 numbers<-c(numbers,Numbers[A,B])}
	else 	{lengths<-c(lengths,Lengths[B,A])
		 numbers<-c(numbers,Numbers[B,A])}
}

jpeg("C:/Users/Student/Desktop/PC_HISTS.jpeg")
par(mfrow=c(1,2))
hist(lengths)
hist(numbers)
dev.off()



######################################################################


lengths2<-integer(0)
numbers2<-integer(0)

for (i in seq(length(GC_FILE[,1])))
{
	if ((A<-which(poplist==GC_FILE[i,1]))<(B<-which(poplist==GC_FILE[i,2])))
	{lengths2<-c(lengths2,Lengths[A,B])
	 numbers2<-c(numbers2,Numbers[A,B])}
	else 	{lengths2<-c(lengths2,Lengths[B,A])
		 numbers2<-c(numbers2,Numbers[B,A])}
}

jpeg("C:/Users/Student/Desktop/GC_HISTS.jpeg")
par(mfrow=c(1,2))
hist(lengths2)
hist(numbers2)
dev.off()


######################################################################


lengths3<-integer(0)
numbers3<-integer(0)

for (i in seq(length(SIB_FILE[,1])))
{
	if ((A<-which(poplist==SIB_FILE[i,1]))<(B<-which(poplist==SIB_FILE[i,2])))
	{lengths3<-c(lengths3,Lengths[A,B])
	 numbers3<-c(numbers3,Numbers[A,B])}
	else 	{lengths3<-c(lengths3,Lengths[B,A])
		 numbers3<-c(numbers3,Numbers[B,A])}
}

jpeg("C:/Users/Student/Desktop/SIB_HISTS.jpeg")
par(mfrow=c(1,2))
hist(lengths3)
hist(numbers3)
dev.off()

######################################################################


lengths4<-integer(0)
numbers4<-integer(0)

for (i in seq(length(HSIB_FILE[,1])))
{
	if ((A<-which(poplist==HSIB_FILE[i,1]))<(B<-which(poplist==HSIB_FILE[i,2])))
	{lengths4<-c(lengths4,Lengths[A,B])
	 numbers4<-c(numbers4,Numbers[A,B])}
	else 	{lengths4<-c(lengths4,Lengths[B,A])
		 numbers4<-c(numbers4,Numbers[B,A])}
}

jpeg("C:/Users/Student/Desktop/HSIB_HISTS.jpeg")
par(mfrow=c(1,2))
hist(lengths4)
hist(numbers4)
dev.off()

######################################################################

allLengths <- rbind(lengths,lengths2,lengths3,lengths4)
allNumbers <- rbind(numbers,numbers2,numbers3,numbers4)

jpeg("C:/Users/Student/Desktop/AllLengths.jpeg")
par(mfrow=c(1,1))
hist(lengths,xlim=c(0,max(Lengths)), col="red",density=10,freq=F, ylim=c(0,.0025), main="Histogram of Length",xlab="red:PC, blue:GC, green:SIB, black:HSIB")
par(new=TRUE)
hist(lengths2,xlim=c(0,max(Lengths)), col="blue",density=20,freq=F, ylim=c(0,.0025),main="",xlab="")
par(new=TRUE)
hist(lengths3,xlim=c(0,max(Lengths)), col="green",density=10, freq=F, ylim=c(0,.0025),main="",xlab="")
par(new=TRUE)
hist(lengths4,xlim=c(0,max(Lengths)), col="black",density=10,freq=F, ylim=c(0,.0025),main="",xlab="")





dev.off()

jpeg("C:/Users/Student/Desktop/AllNumbers.jpeg")
par(mfrow=c(1,1))
hist(allNumbers)
dev.off()
######################################################################
######################################################################

